<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <ui:composition template="/template.xhtml">

        <ui:define name="title">
            <h:outputText value="#{bundle.ListContratoTitle}"></h:outputText>
        </ui:define>

        <ui:define name="body">

            <h:panelGroup id="messagePanel" layout="block">
                <p:growl />
            </h:panelGroup>

            <h:form id="formContratoList">

                <h:panelGroup>

                    <p:dataTable id="tableContrato" value="#{contratoController.items}"
                                 var="item" paginator="true" rows="10" 
                                 emptyMessage="#{bundle.ListContratoEmpty}">

                        <f:facet name="header">#{bundle.ListContratoTitle}</f:facet>

                        <p:column filterBy="#{item.dataContrato}" sortBy="#{item.dataContrato}">
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListContratoTitle_dataContrato}"/>
                            </f:facet>
                            <p:calendar value="#{item.dataContrato}" locale="pt" disabled="true"
                                        pattern="dd/MM/yyyy" />
                        </p:column>

                        <p:column filterBy="#{item.responsavel}" sortBy="#{item.responsavel}">
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListContratoTitle_responsavel}"/>
                            </f:facet>
                            <h:outputText value="#{item.responsavel.toString()}"/>
                        </p:column>

                        <p:column filterBy="#{item.cliente}" sortBy="#{item.cliente}">
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListContratoTitle_cliente}"/>
                            </f:facet>
                            <h:outputText value="#{item.cliente.toString()}"/>
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <p:commandButton action="#{contratoController.prepareCreate}" 
                                                 value="#{bundle.ListContratoCreateLink}" ajax="false"/>
                            </f:facet>
                            <p:commandButton action="#{contratoController.prepareView}" 
                                             value="#{bundle.ListPessoaViewLink}" ajax="false"/>
                            <p:commandButton action="#{contratoController.destroy}" 
                                             value="#{bundle.ListPessoaDestroyLink}" ajax="false"/>
                        </p:column>

                    </p:dataTable>

                </h:panelGroup>

            </h:form>

        </ui:define>
    </ui:composition>

</html>
